window.onload = function() {
    var swiper = new Swiper(".mySwiper", {
        spaceBetween: 30,
        centeredSlides: true,
        autoplay: {
            delay: 2500,
            disableOnInteraction: false,
        },
        pagination: {
            el: ".swiper-pagination",
            clickable: true,
        },
        navigation: {
            nextEl: ".swiper-button-next",
            prevEl: ".swiper-button-prev",
        },
    })

    // API移入移出事件
    let lis = document.querySelectorAll('.muchList li')
    let img1s = document.querySelectorAll('.block-link>img:nth-child(1)')
    let img2s = document.querySelectorAll('.block-link>img:nth-child(2)')
        // let src1 = []
        // let src2 = []
        // img1s.forEach(function(i1, index) {
        //     src1[src1.length] = i1.src

    // })
    // console.log(src1);
    // img2s.forEach(function(i2, index) {
    //     src2[src2.length] = i2.src

    // })
    // console.log(src2);
    // lis.forEach(function(li) {
    //         li.addEventListener('mouseenter', function() {
    //             src1[index].src = src2[index]
    //         })
    //     })
    console.log(lis.length);
    console.log(img1s);
    console.log(img2s);
    // let ps = document.querySelectorAll('.block-link:nth-child(3)')
    lis.forEach(function(li, index) {
        li.addEventListener('mouseenter', function() {
            img1s[index].style.display = 'none'
            img2s[index].style.display = 'block'
            li.style.backgroundColor = '#1271ef'

        })
        li.addEventListener('mouseleave', function() {
            img1s[index].style.display = 'block'
            img2s[index].style.display = 'none'
            li.style.backgroundColor = '#fff'

        })
    })



    //首页第二个轮播图
    let detail_lists = document.querySelectorAll('.detail_list>li')
    let timerID = null
    let index = 0


    function autoplay() {
        timerID = setInterval(function() {
            detail_lists[index].classList.remove('active')
            index++
            if (index === 3) {
                index = 0
            }
            detail_lists[index].classList.add('active')
        }, 1000)
    }
    autoplay()


    // let detail_lists = document.querySelectorAll('.detail_list>li')
    // let index = 0
    // let timerID = setInterval(function() {
    //     detail_lists[index].classList.remove('active')
    //     index++
    //     if (index === 3) {
    //         index = 0
    //     }
    //     detail_lists[index].classList.add('active')

    // }, 1000)

    //logos
    let logos = document.querySelectorAll('.logos li')
    let img1 = document.querySelectorAll('.logos li>img:nth-child(1)')
    let img2 = document.querySelectorAll('.logos li>img:nth-child(2)')
    logos.forEach(function(logo, i) {
        logo.addEventListener('mouseenter', function() {
            img1[i].style.display = 'none'
            img2[i].style.display = 'block'

        })
        logo.addEventListener('mouseleave', function() {
            img1[i].style.display = 'block'
            img2[i].style.display = 'none'

        })
    })



    let gotop = document.querySelector('.gotop')
    window.addEventListener('scroll', function() {
        if (document.documentElement.scrollTop >= 800) {
            gotop.style.display = 'block'
        } else {
            gotop.style.display = 'none'
        }
    })
    gotop.addEventListener('click', function() {
        timerID = setInterval(function() {
            document.documentElement.scrollTop -= 20
            if (document.documentElement.scrollTop === 0) {
                clearInterval(timerID)
                timerID = null
            }
        }, 20)
    })


    let login = document.querySelector('.in .login')
    console.log(login);
    let uname = location.search.substr(10)
    console.log(uname);
    login.textContent = uname

}